While the most information needed to perform OPC tasks is contained in arguments to method calls, there are some component-wide parameters that are not worth repeating in every method call, and also some that have wider effect that influences more than just a single method call. You can obtain and modify these parameters through properties on the EasyDAClient or EasyUAClient object.
For the EasyDAClient object, following are its instance properties, i.e. if you have created multiple EasyDAClient objects, each will have its own copy of them:
- Mode: Specifies common parameters such as allowed and desired methods of accessing the data in the OPC server.
- HoldPeriods: Specifies optimization parameters that reduce the load on the OPC server.
- Timeouts: Specifies the maximum amount of time the various operations are allowed to take.
and
- SynchronizationContext: Contains synchronization context used by the object when performing event notifications.
// This example shows how the OPC server can quickly be disconnected after writing a value into one of its OPC items.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;
namespace DocExamples.DataAccess._EasyDAClientHoldPeriods
{
class TopicWrite
{
public static void Main1()
{
// Instantiate the client object.
var client = new EasyDAClient();
client.InstanceParameters.HoldPeriods.TopicWrite = 100; // in milliseconds
try
{
client.WriteItemValue("", "OPCLabs.KitServer.2", "Simulation.Register_I4", 12345);
}
catch (OpcException opcException)
{
Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
}
}
}
}
# This example shows how the OPC server can quickly be disconnected after writing a value into one of its OPC items.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
# Import .NET namespaces.
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.OperationModel import *
# Instantiate the client object.
client = EasyDAClient()
client.InstanceParameters.HoldPeriods.TopicWrite = 100 # in milliseconds
# Perform the operation
try:
IEasyDAClientExtension.WriteItemValue(client, '', 'OPCLabs.KitServer.2', 'Simulation.Register_I4', 12345)
except OpcException as opcException:
print('*** Failure: ' + opcException.GetBaseException().Message)
exit()
print('Finished.')
' This example shows how the OPC server can quickly be disconnected after writing a value into one of its OPC items.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel
Namespace DataAccess._EasyDAClientHoldPeriods
Friend Class TopicWrite
Public Shared Sub Main1()
Dim client = New EasyDAClient()
client.InstanceParameters.HoldPeriods.TopicWrite = 100 ' in milliseconds
Try
client.WriteItemValue("", "OPCLabs.KitServer.2", "Simulation.Register_I4", 12345)
Catch opcException As OpcException
Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
End Try
End Sub
End Class
End Namespace
For the EasyUAClient object, following are its instance properties, i.e. if you have created multiple EasyUAClient objects, each will have its own copy of them:
- SynchronizationContext: Contains synchronization context used by the object when performing event notifications.
Instance properties can be modified from your code.
In QuickOPC.NET and QuickOPC-UA, if you have placed the EasyDAClient, EasyAEClient or EasyUAClient object on the designer surface, most instance properties can also be directly edited in the Properties window in Visual Studio.
In QuickOPC-COM, your code can override the defaults if needed, by setting the properties accordingly.
Following properties are static, i.e. shared among all instances of EasyDAClient object:
- EngineParameters: Contains global parameters such as frequencies of internal tasks performed by the component.
- MachineParameters: Contains parameters related to operations that target a specific computer but not a specific OPC server, such as browsing for OPC servers using various methods.
- ClientParameters: Contains parameters that influence operations that target a specific OPC server a whole.
- TopicParameters: Contains parameters that influence operations that target a specific OPC item.
Following properties are static, i.e. shared among all instances of EasyUAClient object:
- EngineParameters: Contains global parameters such as frequencies of internal tasks performed by the component.
Following properties are static unless the EasyUAClient is configured as isolated:
- HostParameters: Contains parameters that influence the behavior of the component on the host level.
- DiscoveryParameters: Contains parameters that influence the behavior of the component for the discovery.
- MonitoredItemParameters: Contains parameters related to operations that target a specific monitored item (e.g. a retrial delay).
- SessionParameters: Contains parameters that influence operations that target an OPC-UA session, such as Endpoint Selection Policy, User Identity, and Keep Alive Interval.
- SubscriptionParameters: Contains parameters that influence operations that target an OPC-UA subscription (e.g. a retrial delay).
Please use the Reference documentation for details on meaning of various properties and their use.
Static properties can be modified from your code. If you want to modify any of the static properties, you must do it before the first instance of EasyDAClient , EasyAEClient or EasyUAObject object is created.
You can also use the following components to set the static properties:
In Visual Studio, drag the corresponding component from the Toolbox to the designer surface, select it, and you can then view and modify the settings in the Properties window.
Note that the EasyXXClientConfiguration (where XX is either AE/DA/UA) components are just a “peek” to properties of the EasyXXClient that are static in nature. For this reason, you should normally have just one instance of the EasyXXClientConfiguration component in your application, and you should place it in such a way that it gets instantiated before the first operations on the EasyXXClient object take place. You can achieve this easily e.g. by placing the EasyXXClientConfiguration component onto the main (first) form of your application.
The EasyUAClientManagement component also has a LogEntry event, which functions as a “projection” of the static EasyUAClient.LogEntry event. You can easily hook an event handler to this event to process log entries generated by the EasyUAClient component.
When
Multiple Implementations are available (such as for OPC Data Access, with native and NET API client), not all parameters apply to (are used with) all implementations. In such case, the reference documentation for the affected parameter (property) specifies the circumstances under which the parameter is used.
See Also